< previous page page_273 next page >

Page 273
WillChangeRecord event is triggered. Besides the adStatus parameter, this event contains the parameter adReason that tells you which method invoked this event. By checking the adReason parameter, you can perform different processes depending on the type of action taken against the Data control. Table 10.2 lists the values of the adReason parameter.
TABLE 10.2. THEadReasonPARAMETER VALUES FOR THEWillChangeRecordEVENT.
ConstantValueDescription
adRsnAddNew1AddNew
adRsnDelete2Delete
adRsnUpdate3Update
adRsnUndoUpdate4Undo the Update
adRsnUndoAddNew5Undo the AddNew
adRsnUndoDelete6Undo the Delete
adRsnRequery7Requery the database
adRsnReSync8Resync the query with the database
adRsnClose9The Close method of the Data control was used
adRsnMove10Move
adRsnFirstChange11FirstChange
adRsnMoveFirst12MoveFirst
adRsnMoveNext13MoveNext
adRsnMovePrevious13MovePrevious
adRsnMoveLast15MoveLast

The code you place in these events can be as complex as you need. An example WillChangeField rountine is as follows:
Private Sub log_db_Validate(cFields As ??, Fields As ??, asStatus As ??, pRecordset As ??)
    If Not IsDate(txtDate.Text) Then
            MsgBox The Flight date you entered is Invalid & _
                   vbCRLF & Please Re-enter!, vbCritical, App.Title
            Action = vbDataActionCancel
            txtDate.DataChanged = False
            txtDate.Text = ??/??/??
        End If
    End If
End Sub

 
< previous page page_273 next page >

If you like this book, buy it!